package cn.fenghua.demoproject2.controller;

import cn.fenghua.demoproject2.config.WXConfig;
import cn.fenghua.demoproject2.utils.JsonData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.PropertySource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping("/api/v1/test")
@PropertySource("classpath:pay.properties")
public class TestController {

    @Value("${wxpay.appid}")
    private String payAppId;
    @Value("${wxpay.secret}")
    private String paySecret;

    @Autowired
    WXConfig wxConfig;

    @GetMapping("/get_config")
    public JsonData testConfig() {
        Map<String ,String> map = new HashMap<>();
        map.put("appid", wxConfig.getPayAppId());
        map.put("secret", wxConfig.getPaySecret());
        map.put("mechid", wxConfig.getPayMechId());

        return JsonData.buildSuccess(map);
    }

    @GetMapping("/list")
    public JsonData testList() {
        int i = 1 / 0;
        return JsonData.buildSuccess("");
    }
}
